/**
 * 
 */
package com.baijia.tianxiao.push.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baijia.tianxiao.push.model.UserDeviceAttribute;
import com.baijia.tianxiao.push.result.BaseApiResult;
import com.baijia.tianxiao.push.service.UserDeviceAttributeService;

/**
 * @author leiruiqi
 *
 */
@RequestMapping("/userDeviceAttribute")
@RestController
public class UserDeviceAttributeController {

	@Resource
	private UserDeviceAttributeService userDeviceAttributeService;
	
	@RequestMapping("/addAttribute")
	public BaseApiResult add(HttpServletRequest request,String bizType,String userId,String deviceId,String addAttribute){
		BaseApiResult apiResult = new BaseApiResult();
		
		userDeviceAttributeService.addAttribute(bizType, userId, deviceId, addAttribute);
		
		apiResult.setCode("1");
		return apiResult;
	}
	

	@RequestMapping("/get")
	public BaseApiResult get(String bizType,String userId,String deviceId){
		BaseApiResult apiResult = new BaseApiResult();
		UserDeviceAttribute userDeviceAttribute = userDeviceAttributeService.findByDeviceAndBizUserId(bizType, userId, deviceId);
		
		apiResult.setCode("1");
		apiResult.setData(userDeviceAttribute);
		return apiResult;
	}
	
	@RequestMapping("/queryByUidPrefix")
	public BaseApiResult queryByUserIdPrefix(String bizType,String userIdPrefix){
		BaseApiResult apiResult = new BaseApiResult();
		
		List<UserDeviceAttribute> list = userDeviceAttributeService.queryByBizAndUserIdPrefix(bizType, userIdPrefix);
		
		apiResult.setCode("1");
		apiResult.setData(list);
		return apiResult;
	}
	
	@RequestMapping("/queryByUid")
	public BaseApiResult queryByUserId(String bizType,String userId){
		BaseApiResult apiResult = new BaseApiResult();
		
		List<UserDeviceAttribute> list = userDeviceAttributeService.queryByBizAndUserId(bizType, userId);
		
		apiResult.setCode("1");
		apiResult.setData(list);
		return apiResult;
	}
	
}
